home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / fragment tool / fragmentstuff.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.8 KB  |  131 lines

  1. /*
  2.     File:        FragmentStuff.h
  3.  
  4.     Contains:    Data structures which define the 'cfrg' resource format
  5.                 and a our own independent data structure containing the
  6.                 information we need, in a simple format.
  7.  
  8.     Written by: Chris White    
  9.  
  10.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  11.  
  12.                 You may incorporate this Apple sample source code into your program(s) without
  13.                 restriction. This Apple sample source code has been provided "AS IS" and the
  14.                 responsibility for its operation is yours. You are not permitted to redistribute
  15.                 this Apple sample source code as "Apple sample source code" after having made
  16.                 changes. If you're going to re-distribute the source, we require that you make
  17.                 it clear in the source that the code was descended from Apple sample source
  18.                 code, but that you've made changes.
  19.  
  20.     Change History (most recent first):
  21.                 8/5/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  22.                 
  23.  
  24. */
  25.  
  26.  
  27. #ifndef __FRAGMENTSTUFF__
  28. #define __FRAGMENTSTUFF__
  29.  
  30.  
  31.  
  32. #ifndef __TYPES__
  33.     #include <Types.h>
  34. #endif
  35.  
  36.  
  37.  
  38.  
  39. // The format of the 'cfrg' on disk. This is defined in <CodeFragmentTypes.r>
  40. #ifdef powerc
  41.     #pragma options align=mac68k
  42. #endif
  43.  
  44.  
  45. struct cfrgHeader
  46. {
  47.     long     res1;
  48.     long     res2;
  49.     long     version;
  50.     long     res3;
  51.     long     res4;
  52.     long     filler1;
  53.     long     filler2;
  54.     long     itemCount;
  55.     char    arrayStart;    // Array of externalItems begins here
  56. };
  57. typedef struct cfrgHeader cfrgHeader, *hdrPtr, **hdrHand;
  58.  
  59. struct cfrgItem
  60. {
  61.     OSType     archType;
  62.     long     updateLevel;
  63.     long    currVersion;
  64.     long    oldDefVersion;
  65.     long    appStackSize;
  66.     short    appSubFolder;
  67.     char    usage;
  68.     char    location;
  69.     long    codeOffset;
  70.     long    codeLength;
  71.     long    res1;
  72.     long    res2;
  73.     short    itemSize; // %4 == 0
  74.     Str255    name;
  75.     // Only make the final p-string as long as needed, then align to
  76.     // a longword boundary
  77. };
  78. typedef struct cfrgItem cfrgItem;
  79. #ifdef powerc
  80.     #pragma options align=reset
  81. #endif
  82.  
  83.  
  84. struct TempFileRec
  85. {
  86.     int        usageCount;
  87.     FSSpec    fileSpec;
  88. };
  89.  
  90. typedef struct TempFileRec tTempFileRec, *tTempFilePtr;
  91.  
  92.  
  93. /* Record for each fragment. Includes simplified version of the 'cfrg' data */
  94. struct internalItem
  95. {
  96.     /* Data used for the application */
  97.     Boolean            bDeleted;
  98.     Boolean            bExistsInDocument;
  99.     tTempFilePtr    tempFilePtr;
  100.     
  101.     /* Data included in the 'cfrg' resource */
  102.     OSType     archType;
  103.     long     updateLevel;
  104.     long    currVersion;
  105.     long    oldDefVersion;
  106.     long    appStackSize;
  107.     short    appSubFolder;
  108.     short    usage;
  109.     short    location;
  110.     long    codeOffset;
  111.     long    codeLength;
  112.     Str255    name;
  113. };
  114. typedef struct internalItem tItem, *tItemPtr;
  115.  
  116. struct internalResource {
  117.     long             version;
  118.     long             itemCount;
  119.     tItem            itemList[1];
  120. };
  121. typedef struct internalResource tHeader, *tHeaderPtr, **tHeaderHan;
  122.  
  123. /* ===== Prototypes ===== */
  124. OSErr ParseResource (Handle theResource, tHeaderHan internalCopy);
  125. OSErr BuildResource (tHeaderHan internalCopy, Handle theResource);
  126.  
  127.  
  128.  
  129.  
  130. #endif // define __FRAGMENTS__
  131.